package com.leetcode.August;

/**
 * @Description: 167. 两数之和 II - 输入有序数组
 * @Author: Mr.Fxy
 * @CreateTime: 2024-08-24 09:26
 */
public class LC167两数之和II输入有序数组 {
    public int[] twoSum(int[] numbers, int target) {
        int left=0,right = numbers.length-1;
        while (true){
            if(numbers[left]+numbers[right]==target){
                return new int[]{left+1,right+1};
            }else if(numbers[left]+numbers[right]>target){
                right--;
            }else {
                left++;
            }
        }
    }
}
